
import request from '@/api/config/request'
import { IRole, IRoleState } from '@/store/modules/role'
import { ApiResponse } from './type'

// 获取角色
export interface RoleParams {
  rolename?: string
  pageNum: number;
  pageSize: number;
}

export const getRoles = (data: RoleParams): Promise<ApiResponse<IRoleState>> => {
  return request.post('/role/findAll', data)
}

// 删除角色
export const removeRole = (id: number): Promise<ApiResponse<null>> => {
  return request.delete(`/role/remove/${id}`)
}

// 添加角色
export const addRole = (data: IRole): Promise<ApiResponse<null>> => {
  return request.post('/role/add', data)
}

// 编辑角色
export const updateRole = (id: number, data: IRole): Promise<ApiResponse<null>> => {
  return request.patch(`/role/update/${id}`, data)
}
